function [coefficients, scores, variances] = pca(dataset)

'1) get size..'
[rows columns] = size(dataset);

% normalize the dataset by subtarcting the sample mean and then dividing by
% the standard deviation 
'2) get mean...'
AMean = mean(dataset);
'3) get standard deviation...'
AStd = std(dataset);
%'4) adjust data...'
%adj_dataset = (dataset - repmat(AMean,[rows 1])) ./ repmat(AStd,[rows 1]);

% find the eigenfunctions of the sample covariance matrix
% V contains the coefficients of the principal components
% the diagonal entries of D contain the variances corresponding to each
% component
'5) do eigen analysis...'
[coefficients variances] = eig(cov(dataset));

% compute actual components and variances
'6) compute components...'
scores = dataset * coefficients;
'7) get variances...'
variances = diag(variances);

end